<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<!-- 
		Replace path to template, title, header and body
		with actual data.
	 -->
<ui:composition template="../template/layout.xhtml">
	<ui:define name="titulo">#{requisicaoControle.tituloPagina}</ui:define>

	<ui:define name="frConteudo">
		<h:form id="form">
			<!-- 
							<h:outputLabel value="" />
							<h:inputHidden value="#{requisicaoControle.infoBean.id}" />
							-->
			<h:panelGrid columns="1" border="0" height="100%">

				<!-- bloco de edição -->
				<p:panel header="#{requisicaoControle.tituloPagina}"
					rendered="#{requisicaoControle.estadoCrud}">
					<h:panelGrid columns="1">
						<f:facet name="header">
							<p:messages id="msgErro" />
						</f:facet>
						<h:panelGrid border="0" columns="2"
							rendered="#{!requisicaoControle.estadoFormVazio}">
							<h:outputLabel value="#{msg.requisicaoNumDoc}" for="numeroDoc" />
							<h:inputText id="numeroDoc" label="#{msg.requisicaoNumDoc}"
								size="15" maxlength="15"
								value="#{requisicaoControle.infoBean.numeroDocumento}"
								required="true"
								requiredMessage="#{msg.requisicaoNumDocRequiredMessage}" />

							<h:outputLabel value="#{msg.requisicaoMesRef}" for="mesReferente" />
							<h:inputText id="mesReferente" label="#{msg.requisicaoMesRef}"
								value="#{requisicaoControle.infoBean.mesReferente}"
								required="true" size="30" maxlength="30"
								requiredMessage="#{msg.requisicaoMesRefRequiredMessage}">
								<f:validateLength minimum="10" maximum="30" />
							</h:inputText>

							<h:outputLabel value="#{msg.statusRequisicao}" for="status" />
							<h:selectOneMenu id="status"
								value="#{requisicaoControle.infoBean.statusRequisicao}"
								required="true"
								requiredMessage="#{msg.statusRequisicaoRequiredMessage}">
								<f:selectItems
									value="#{statusRequisicaoControle.itemsAvailableSelectOne}" />
							</h:selectOneMenu>

							<h:outputLabel value="#{msg.requisicaoObs}" for="observacao" />
							<h:inputTextarea id="observacao" label="#{msg.requisicaoObs}"
								value="#{requisicaoControle.infoBean.observacao}"
								required="true"
								requiredMessage="#{msg.requisicaoObsRequiredMessage}" rows="3"
								cols="40" />

							

							<f:facet name="footer">
									<center>
									<p:separator/>
									<h:outputLabel value="Items da Requisição" />
									<p:separator/>
							<p:pickList value="#{requisicaoControle.listaPedidos}" var="pedido"
								iconOnly="true" effect="bounce" itemLabel="#{pedido.referenciaCI}"
								itemValue="#{pedido}" converter="pedido">
								<f:facet name="sourceCaption">Pedidos disponíveis</f:facet>
								<f:facet name="targetCaption">Pedidos seleccionados</f:facet>
							</p:pickList>
							<br />
								<h:panelGroup>
										<h:commandButton id="salvarButton" value="#{msg.salvarButton}"
											action="#{requisicaoControle.gravar}"
											rendered="#{requisicaoControle.estadoAdicionar}" />
										<h:commandButton id="alterarButton"
											value="#{msg.alterarButton}"
											action="#{requisicaoControle.gravar}"
											rendered="#{requisicaoControle.estadoActualizar}" />
										<h:commandButton id="eliminarButton"
											value="#{msg.eliminarButton}"
											action="#{requisicaoControle.excluir}"
											rendered="#{requisicaoControle.estadoEliminar}"
											onclick="if(!confirm('Confirma a exclusão do registo?')) return false;" />
										<h:commandButton id="limparButton" value="#{msg.limparButton}"
											type="reset" rendered="#{requisicaoControle.estadoAdicionar}" />
										<h:commandButton id="cancelarButton"
											value="#{msg.cancelarButton}"
											action="#{requisicaoControle.voltar}" immediate="true" />
								</h:panelGroup>
									</center>
							</f:facet>
						</h:panelGrid>
					</h:panelGrid>
				</p:panel>
				<!-- fim do bloco de edição -->
			</h:panelGrid>
			<h:panelGroup>
				<h:commandLink action="#{requisicaoControle.voltar}"
					immediate="true" value="#{msg.geralLinkListaRegistos}" />
			</h:panelGroup>
		</h:form>
	</ui:define>
</ui:composition>
</html>
